package com.itheima.ydd.common;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


@Data
@NoArgsConstructor
@AllArgsConstructor
public class R1<T> {

    private Integer errno; //编码：1成功，0和其它数字为失败

    private String errmsg; //错误信息

    private Object data; //数据

    //泛型: 定义时类型不明确, 调用时类型明确
    public static  R1 success(Object object) {
        R1 r = new R1();
        r.errmsg="";
        r.data = object;
        r.errno = 0;
        return r;
    }

    public static  R1 error(String msg) {
        R1 r = new R1();
        r.errmsg = msg;
        r.errno = 1;
        return r;
    }

}
